package com.lmonkey.servlet.cart;

import com.lmonkey.dao.Basedao;
import com.lmonkey.servic.CARTDao;

import javax.naming.ldap.PagedResultsControl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

@WebServlet("/shangc/cartshopdel")
public class CartShopDel extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        //获取数据
        String id = request.getParameter("esid");
        //连接数据库
        Connection conn = Basedao.getconn();
        PreparedStatement ps =null;
        try {
            String sql = "delete from lmonkey_cart where cart_id = ?";
            ps = conn.prepareStatement(sql);
            ps.setInt(1,Integer.parseInt(id));
            ps.executeUpdate();
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
